﻿//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.ApplicationSettings;
using Expenses.ViewModels;
using Windows.System.UserProfile;

namespace Expenses.Views
{
    public sealed partial class ResetDataUserControl : UserControl
    {
        string currentUserName = string.Empty;

        public ResetDataUserControl()
        {
            this.InitializeComponent();
        }

        private void OnBackButtonClicked(object sender, RoutedEventArgs e)
        {
            if (this.Parent.GetType() == typeof(Popup))
            {
                ((Popup)this.Parent).IsOpen = false;
            }
            SettingsPane.Show();
        }

        private async void ResetDataButton_Click(object sender, RoutedEventArgs e)
        {
            var employeeViewModel = new EmployeeViewModel();
            string result = await employeeViewModel.ResetData(App.EmployeeId);
            if (result.Contains("Success"))
            {
                ResultTextBlock.Text = "Your data was reset. Restart the App.";
            }
            else
            {
                ResultTextBlock.Text = "Your data was not reset.";
            }
        }

    }
}
